// 需要缓存的key
const cacheNames = ["searchRecord"]

export default {
  state: {
    searchRecord: [],
    // 电影匹配颜色
    filmCoverColors: [
      "#51655E",
      "#2C154D",
      "#565A7F",
      "#B5B5F1",
      "#809948",
      "#72997A",
      "#09547E",
      "#288E9B",
      "#6E2647",
      "#A24B37",
      "#804549",
      "#7D7F7C",
      "#2F417F",
      "#26354C",
      "#4E4946",
      "#2F4C14",
      "#996A26"
    ]
  },
  getters: {
    searchRecord: (state) => state.searchRecord,
    filmCoverColors: (state) => state.filmCoverColors
  },
  mutations: {
    // 自动初始化
    INIT(state) {
      // 初始化本地缓存
      cacheNames.forEach((name) => {
        let data = uni.getStorageSync(name)
        if (data) state[name] = data
      })
    },
    SET_SEARCH_RECORD(state, data) {
      state.searchRecord = data
      uni.setStorageSync("searchRecord", data)
    }
  },
  actions: {}
}
